import {Controller, Render, Get, Param, Session} from "routing-controllers";
import { utils } from "../../utils/utils";
import { Service, Inject } from "typedi";
import { CourseServiceImpl } from "../../service/impl/CourseServiceImpl";

@Service()
@Controller()
export class CourseControllerHome {
  
  @Inject()
  private courseServiceImpl:CourseServiceImpl;
  
  @Get("/course/:type")
  @Render("home/page/course")
  public async Course(@Session() session, @Param("type") type: string): Promise<Object> {
    return {
      title: utils.titleName("课程"),
      isShowAction: {
        header: true,
        footer: true
      },
      classList: await this.courseServiceImpl.getClassList(),
      courseList: await this.courseServiceImpl.getCourseList(type),
      banner: {
        bannerTitle: '怪客课程',
        bannerUrl: '/img/banner_1.png'
      },
      login: session.user ? session.user : false
    }
  }
}